/*
    SUSAN® - Sole of Unix Save ANything

   
      Copyright (C) 2011-2016 Skyatlas Co. LTD

   

   
*/
/*
 * Kern Sibbald, Sep MM
 */
/**
 * @file
 * Bareos User Agent specific configuration and defines
 */

#ifndef BAREOS_CONSOLE_CONSOLE_CONF_H_
#define BAREOS_CONSOLE_CONSOLE_CONF_H_ 1

#include <string>
#include "lib/parse_conf.h"

class ConfigurationParser;

namespace console {

static const std::string default_config_filename("bconsole.conf");

/**
 * Resource codes -- they must be sequential for indexing
 */

enum
{
  R_CONSOLE = 1001,
  R_DIRECTOR,
  R_FIRST = R_CONSOLE,
  R_LAST = R_DIRECTOR /* Keep this updated */
};

enum
{
  R_NAME = 1020,
  R_ADDRESS,
  R_PASSWORD,
  R_TYPE,
  R_BACKUP
};

class ConsoleResource
    : public BareosResource
    , public TlsResource {
 public:
  ConsoleResource() = default;
  virtual ~ConsoleResource() = default;

  char* rc_file = nullptr;       /**< startup file */
  char* history_file = nullptr;  /**< command history file */
  s_password password;           /**< UA server password */
  uint32_t history_length = 0;   /**< readline history length */
  char* director = nullptr;      /**< bind to director */
  utime_t heartbeat_interval{0}; /**< Interval to send heartbeats to Dir */
};

class DirectorResource
    : public BareosResource
    , public TlsResource {
 public:
  DirectorResource() = default;
  virtual ~DirectorResource() = default;

  uint32_t DIRport = 0;          /**< UA server port */
  char* address = nullptr;       /**< UA server address */
  utime_t heartbeat_interval{0}; /**< Interval to send heartbeats to Dir */
};

ConfigurationParser* InitConsConfig(const char* configfile, int exit_code);
bool PrintConfigSchemaJson(PoolMem& buffer);

} /* namespace console */
#endif /* BAREOS_CONSOLE_CONSOLE_CONF_H_ */
